package behavior.strategy.versionThree;

import java.math.BigDecimal;

/**
 * @author huhaiqiang
 * @version V1.0
 * @description 具体算法二
 * @date 2018/12/03 17:43
 */
public class ConcreteStrategyTwo extends CashSuperStrategy {

    /**
     * 输入金额
     */
    private BigDecimal moneyCondition;

    /**
     * 返利金额
     */
    private BigDecimal moneyReturn;

    ConcreteStrategyTwo(BigDecimal moneyCondition, BigDecimal moneyReturn) {
        this.moneyCondition = moneyCondition;
        this.moneyReturn = moneyReturn;
    }

    /**
     * 具体策略实现
     * @param money 原价
     * @return result 折扣后价格
     */
    @Override
    public BigDecimal acceptCash(BigDecimal money) {
        BigDecimal result = money;
        if (money.compareTo(moneyCondition) != -1) {
            result = money.subtract(moneyReturn);
        }
        return result;
    }
}
